package com.wtpaint.leetcode.查找表;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class IsAnagram242 {

    public static boolean isAnagram(String s, String t) {
        if (s == null || t == null || s.length() != t.length()) {
            return false;
        }

        char[] sChars = s.toCharArray();
        char[] tChars = t.toCharArray();

//        int length = sChars.length;
//        Map<Character, Character> resChar = new HashMap();
//        for (int i = 0; i < length; i++) {
//            if (sChars[i] == tChars[i]) {
//                resChar.put(sChars[i], tChars[i]);
//            } else {
//                if (resChar.get(sChars[i]) == null) {
//                    resChar.put(sChars[i], tChars[i]);
//                } else {
//                }
//            }
//        }
        Arrays.sort(sChars);
        Arrays.sort(tChars);

        return Arrays.equals(sChars, tChars);


    }


    public static void main(String[] args) {
        System.out.println("  " + isAnagram("anagram", "nagaram"));
        System.out.println("  " + isAnagram("rat", "car"));
    }
}
